package dk.itu.samd.group2.tagapastry.indexing;

import java.util.Vector;

import rice.p2p.commonapi.NodeHandle;
import dk.itu.samd.group2.tagapastry.IndexRelative;
import dk.itu.samd.group2.tagapastry.Tag;
import dk.itu.samd.group2.tagapastry.Tagapastry;
import dk.itu.samd.group2.tagapastry.TagapastryImpl;
import dk.itu.samd.group2.tagapastry.messages.IndexRetractionRequestMsg;


/*
 * Implements one of the retraction strategies
 */
public class SimpleRetractionStrategy implements RetractionStrategy {

	private TagapastryImpl tagaImpl;

	public SimpleRetractionStrategy(TagapastryImpl impl) {

		this.tagaImpl = impl;
	}

	/*
	 * (non-Javadoc)
	 * @see dk.itu.samd.group2.indexing.RetractionStrategy#retract()
	 */
	//	public void retract(int cEntries, Tag tag, NodeHandle sender, IndexRelative[] children) {
	//
	//	}

	public void retract(Vector<IndexRelative> children) {
		//System.out.println("Calling IndexRetraction...");
		for (IndexRelative child : children) {
			
			
			
			child.retract(tagaImpl);
			
			
		
		}


	}

	//	private int countNotNullChidlren(IndexRelative[] children) {
	//		
	//		if(children == null)
	//			return 0;
	//		
	//		int num=0;
	//		for(IndexRelative i : children) {
	//			if(i != null) {
	//				num++;
	//			}
	//		}
	//		
	//		return num;
	//	}

}
